$(function() {
	get_student_grade()
	search()
})
URL = '/student_grades/query_method/'

function get_student_grade(form_data) {
	var $students_grade_table = $("#students_grade")
	var select = {
		"query_method": "count_fail_by_major"
	}
	for (var item in form_data) {
		select[form_data[item].name] = form_data[item].value
	}
	$students_grade_table.bootstrapTable("showLoading");
	$.post(URL, select, function(data) {
		$students_grade_table.bootstrapTable("destroy");
		$students_grade_table.bootstrapTable({
			cache: false,
			data: zip(data["description"],data["result"])
		})
	})
}

function search() {
	$("#search").submit(function(e) {
		var form_data = $("#search").serializeArray();
		var form_object = {};
		for (var item in form_data) {
			form_object[form_data[item].name] = form_data[item].value;
		}
		get_student_grade(form_data)
		return false;
	})
}
